<?php
class MyCategory
{
    
    //品牌商城类别id
    static $xfq_category_id = 63;
    
    //积分上海层类别id
    static $point_category_id = 64;
    
    static $second_level_category_key_voucher = 'voucher';
    static $second_level_category_key_point   = 'point';
    
    /**
     * 根据分类id得到分类对象
     * @param unknown $id
     */
    static function get_category_obj($id)
    {
        $model = new Model();
        return $model->table("goods_category")->where("id=$id")->find();
    }
    
    
    /**
     * 根据商品1级分类类别得到商品2级分类列表
     * @param unknown $first_level_category
     */
    static function get_goods_second_level_category_list($category_type)
    {
        $model = new Model();
        if($category_type == 'voucher')//消费券
        {
            $demo_cid = self::$xfq_category_id;
            $where_str = "parent_id=".self::$xfq_category_id;
        }
        elseif($category_type == 'point')//积分
        {
            $demo_cid = self::$point_category_id;
            $where_str = "parent_id=".self::$point_category_id;
        }
        
        $file_cache_list = unserialize( FileSecacheDo::get($category_type));
        //如果缓存为空，则直接去数据库查
        if(empty($file_cache_list))
        {
            $list = $model->table("goods_category")->where("parent_id=".$demo_cid)->select();
            FileSecacheDo::set($category_type, serialize($list));
            return $list;
        }
        else
        {
            return $file_cache_list;
        }
        
    }
    
    /**
     * 根据第2级类别id得到商品第3级分类列表
     * @param unknown $category_id
     */
    static function get_goods_third_level_category_list($category_id)
    {
        $model = new Model();
        $list = $model->table("goods_category")->where("parent_id=".$category_id)->select();
        return $list;
    }
    
    
}
?>